home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
minix
/
up1510b.tgz
/
up1510b
/
src
/
commands
/
sh
/
sh5.c.D
< prev
next >
Wrap
Text File
|
1990-07-25
|
9KB
|
435 lines
*** /tmp/,RCSt1022169 Wed Jul 25 13:44:42 1990
--- sh5.c Thu Jul 12 01:03:31 1990
***************
*** 1,5 ****
#define Extern extern
! #include "signal.h"
! #include "errno.h"
! #include "setjmp.h"
#include "sh.h"
--- 1,6 ----
#define Extern extern
! #include <sys/types.h>
! #include <signal.h>
! #include <errno.h>
! #include <setjmp.h>
#include "sh.h"
***************
*** 13,15 ****
--- 14,21 ----
+ static struct iobuf sharedbuf = {AFID_NOBUF};
+ static struct iobuf mainbuf = {AFID_NOBUF};
+ static unsigned bufid = AFID_ID; /* buffer id counter */
+ struct ioarg temparg = {0, 0, 0, AFID_NOBUF, 0};
+
int
***************
*** 28,30 ****
c = readc();
! if (ec != '\'') {
if(c == '\\') {
--- 34,36 ----
c = readc();
! if (ec != '\'' && ec != '`' && e.iop->task != XGRAVE) {
if(c == '\\') {
***************
*** 47,48 ****
--- 53,61 ----
int
+ eofc()
+
+ {
+ return e.iop < e.iobase || (e.iop->peekc == 0 && e.iop->prev == 0);
+ }
+
+ int
readc()
***************
*** 50,52 ****
register c;
- static int eofc;
--- 63,64 ----
***************
*** 56,68 ****
return(c);
- } else if ((c = (*e.iop->iofn)(&e.iop->arg, e.iop)) != '\0') {
- if (c == -1) {
- e.iop++;
- continue;
- }
- if (e.iop == iostack)
- ioecho(c);
- return(c);
}
! if (e.iop >= iostack ||
! multiline && eofc++ < 3)
return(0);
--- 68,96 ----
return(c);
}
! else {
! if (e.iop->prev != 0) {
! if ((c = (*e.iop->iofn)(e.iop->argp, e.iop)) != '\0') {
! if (c == -1) {
! e.iop++;
! continue;
! }
! if (e.iop == iostack)
! ioecho(c);
! return(e.iop->prev = c);
! }
! else if (e.iop->task == XIO && e.iop->prev != '\n') {
! e.iop->prev = 0;
! if (e.iop == iostack)
! ioecho('\n');
! return '\n';
! }
! }
! if (e.iop->task == XIO) {
! if (multiline)
! return e.iop->prev = 0;
! if (talking && e.iop == iostack+1)
! prs(prompt->value);
! }
! }
! if (e.iop >= iostack)
return(0);
***************
*** 81,84 ****
void
! pushio(arg, fn)
! struct ioarg arg;
int (*fn)();
--- 109,112 ----
void
! pushio(argp, fn)
! struct ioarg *argp;
int (*fn)();
***************
*** 92,94 ****
e.iop->iofn = fn;
! e.iop->arg = arg;
e.iop->peekc = 0;
--- 120,138 ----
e.iop->iofn = fn;
!
! if (argp->afid != AFID_NOBUF)
! e.iop->argp = argp;
! else {
! e.iop->argp = ioargstack + (e.iop - iostack);
! *e.iop->argp = *argp;
! e.iop->argp->afbuf = e.iop == &iostack[0] ? &mainbuf : &sharedbuf;
! if (isatty(e.iop->argp->afile) == 0 &&
! (e.iop == &iostack[0] ||
! lseek(e.iop->argp->afile, 0L, 1) != -1)) {
! if (++bufid == AFID_NOBUF)
! bufid = AFID_ID;
! e.iop->argp->afid = bufid;
! }
! }
!
! e.iop->prev = ~'\n';
e.iop->peekc = 0;
***************
*** 96,98 ****
e.iop->nlcount = 0;
! if (fn == filechar || fn == linechar || fn == nextchar)
e.iop->task = XIO;
--- 140,142 ----
e.iop->nlcount = 0;
! if (fn == filechar || fn == linechar)
e.iop->task = XIO;
***************
*** 164,166 ****
*/
! static int xxchar(), qqchar();
--- 208,210 ----
*/
! static int xxchar();
***************
*** 173,175 ****
if ((wp = *ap->awordlist++) != NULL) {
! PUSHIO(aword, wp, *ap->awordlist == NULL? qqchar: xxchar);
return(-1);
--- 217,219 ----
if ((wp = *ap->awordlist++) != NULL) {
! PUSHIO(aword, wp, *ap->awordlist == NULL? strchar: xxchar);
return(-1);
***************
*** 194,197 ****
! static int
! qqchar(ap)
register struct ioarg *ap;
--- 238,244 ----
! /*
! * Produce the characters from a single word (string).
! */
! int
! strchar(ap)
register struct ioarg *ap;
***************
*** 200,202 ****
! if (ap->aword == NULL || (c = *ap->aword++) == '\0')
return(0);
--- 247,249 ----
! if (ap->aword == NULL || (c = *ap->aword++) == 0)
return(0);
***************
*** 206,208 ****
/*
! * Produce the characters from a single word (string).
*/
--- 253,255 ----
/*
! * Produce quoted characters from a single word (string).
*/
***************
*** 209,211 ****
int
! strchar(ap)
register struct ioarg *ap;
--- 256,258 ----
int
! qstrchar(ap)
register struct ioarg *ap;
***************
*** 214,218 ****
! if (ap->aword == 0 || (c = *ap->aword++) == 0)
return(0);
! return(c);
}
--- 261,265 ----
! if (ap->aword == NULL || (c = *ap->aword++) == 0)
return(0);
! return(c|QUOTE);
}
***************
*** 228,229 ****
--- 275,277 ----
char c;
+ struct iobuf *bp = ap->afbuf;
extern int errno;
***************
*** 230,231 ****
--- 278,297 ----
+ if (ap->afid != AFID_NOBUF) {
+ if ((i = ap->afid != bp->id) || bp->bufp == bp->ebufp) {
+ if (i)
+ lseek(ap->afile, ap->afpos, 0);
+ do {
+ i = read(ap->afile, bp->buf, sizeof(bp->buf));
+ } while (i < 0 && errno == EINTR);
+ if (i <= 0) {
+ closef(ap->afile);
+ return 0;
+ }
+ bp->id = ap->afid;
+ bp->ebufp = (bp->bufp = bp->buf) + i;
+ }
+ ap->afpos++;
+ return *bp->bufp++ & 0177;
+ }
+
do {
***************
*** 315,333 ****
- /*
- * Return the next character from the command source,
- * prompting when required.
- */
- int
- nextchar(ap)
- register struct ioarg *ap;
- {
- register int c;
-
- if ((c = filechar(ap)) != 0)
- return(c);
- if (talking && e.iop <= iostack+1)
- prs(prompt->value);
- return(0);
- }
-
void
--- 381,382 ----
***************
*** 435,440 ****
! static char *readhere();
- #define NCPB 100 /* here text block allocation unit */
-
markhere(s, iop)
--- 484,487 ----
! static void readhere();
markhere(s, iop)
***************
*** 452,453 ****
--- 499,501 ----
h->h_iop = iop;
+ iop->io_name = 0;
h->h_next = NULL;
***************
*** 472,483 ****
{
! register struct here *h;
! for (h = inhere; h != NULL; h = inhere) {
! h->h_iop->io_name = readhere(h->h_tag, h->h_dosub? 0: '\'');
! /* relink from inhere to acthere list */
! inhere = h->h_next;
! h->h_next = acthere;
! acthere = h;
}
- inhere = h;
}
--- 520,533 ----
{
! register struct here *h, *hp;
! /* Scan here files first leaving inhere list in place */
! for (hp = h = inhere; h != NULL; hp = h, h = h->h_next)
! readhere(&h->h_iop->io_name, h->h_tag, h->h_dosub? 0: '\'');
!
! /* Make inhere list active - keep list intact for scraphere */
! if (hp != NULL) {
! hp->h_next = acthere;
! acthere = inhere;
! inhere = NULL;
}
}
***************
*** 484,487 ****
! static char *
! readhere(s, ec)
register char *s;
--- 534,538 ----
! static void
! readhere(name, s, ec)
! char **name;
register char *s;
***************
*** 496,497 ****
--- 547,549 ----
tempname(tname);
+ *name = strsave(tname, areanum);
tf = creat(tname, 0600);
***************
*** 498,532 ****
if (tf < 0)
! return (0);
if (newenv(setjmp(errpt = ev)) != 0)
! return (0);
! if (e.iop == iostack && e.iop->iofn == filechar) {
! pushio(e.iop->arg, filechar);
e.iobase = e.iop;
! }
! for (;;) {
! if (talking && e.iop <= iostack)
! prs(cprompt->value);
! next = line;
! while ((c = getc(ec)) != '\n' && c) {
! if (ec == '\'')
! c &= ~ QUOTE;
! if (next >= &line[LINELIM]) {
! c = 0;
! break;
}
! *next++ = c;
}
! *next = 0;
! if (strcmp(s, line) == 0 || c == 0)
! break;
! *next++ = '\n';
! write (tf, line, (int)(next-line));
}
- if (c == 0) {
- prs("here document `"); prs(s); err("' unclosed");
- }
close(tf);
- quitenv();
- /* correct area? */
- return (strsave(tname, areanum));
}
--- 550,582 ----
if (tf < 0)
! return;
if (newenv(setjmp(errpt = ev)) != 0)
! unlink(tname);
! else {
! pushio(e.iop->argp, e.iop->iofn);
e.iobase = e.iop;
! for (;;) {
! if (talking && e.iop <= iostack)
! prs(cprompt->value);
! next = line;
! while ((c = getc(ec)) != '\n' && c) {
! if (ec == '\'')
! c &= ~ QUOTE;
! if (next >= &line[LINELIM]) {
!